home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / EPSVIEWE.M < prev    next >
Text File  |  1992-03-25  |  3KB  |  87 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: EpsViewer.m,v 3.24 1992/02/29 16:27:40 woo Exp woo $";
  3. #endif
  4.  
  5. /*
  6.  * $Log: EpsViewer.m,v $
  7. # Revision 3.24  1992/02/29  16:27:40  woo
  8. # gnuplot3.2, beta 4
  9. #
  10.  */
  11.  
  12. #import "EpsViewer.h"
  13. #import "EPSView.h"
  14. #import <appkit/nextstd.h>
  15. #import <appkit/OpenPanel.h>
  16.  
  17. @implementation EpsViewer
  18.  
  19. - windowCreate:(NXCoord) width Height:(NXCoord) height
  20. {
  21.     NXRect rect = {{0.0,0.0},{width,height}};
  22.     
  23.     /* create the new window, in a good place */
  24.     theNewWin = [Window
  25.         newContent:[self nextRectForWidth:width Height:height]
  26.         style:NX_TITLEDSTYLE
  27.         backing:NX_RETAINED
  28.         buttonMask:(NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK)
  29.         defer:NO];
  30.     /* we need to receive windowDidBecomeMain: and windowDidResignMain: */
  31.     [theNewWin setDelegate:self];
  32.     /*
  33.      * create a new EPSView, make it the contentView of our new window,
  34.      * and destroy the window's old contentView 
  35.      */
  36.     [[theNewWin setContentView:[EPSView new]] free];
  37.         /* display the window, and bring it forth */
  38.     [theNewWin display];
  39.     [theNewWin makeKeyAndOrderFront:self];    
  40. /*    [theNewWin orderBack:self];            */
  41.     /* show the frame */
  42.     return self;
  43. }
  44.  
  45. /***************************************************************************/
  46. /* nextRectForWidth:Height: - return the next good content rectangle       */
  47. /*  from Carl F. Sutter's wonderful ViewGif2 'Controller' method...        */
  48. /***************************************************************************/
  49. /* nextTopLeft - return the next good top left window position           */
  50. /***************************************************************************/
  51.  
  52. - (NXRect *)nextRectForWidth:(NXCoord)width Height:(NXCoord)height
  53. {
  54. #define OFFSET 10.0
  55. #define MAX_STEPS 20
  56. #define INITIAL_X 356.0
  57. #define INITIAL_Y 241.0
  58.     NXPoint         nxpTopLeft;
  59.     NXRect          nxrTemp;    /* used to find window height     */
  60.     NXRect          nxrWinHeight;    /* bounds of enclosing window     */
  61.     NXSize          nxsScreen;    /* size of screen         */
  62.     static NXRect   nxrResult;    /* the Answer!             */
  63.     static int      nCurStep = 0;
  64.  
  65.     /* find a good top-left coord */
  66.     nxpTopLeft.x = INITIAL_X + nCurStep * OFFSET;
  67.     nxpTopLeft.y = INITIAL_Y + nCurStep * OFFSET;
  68.     if (++nCurStep > MAX_STEPS)
  69.         nCurStep = 0;
  70.     /* find window height using nxrTemp */
  71.     nxrTemp.size.width = width;
  72.     nxrTemp.size.height = height;
  73.     nxrTemp.origin.x = nxrTemp.origin.y = 0;
  74.     [Window getFrameRect:&nxrWinHeight forContentRect:&nxrTemp
  75.      style:NX_TITLEDSTYLE];
  76.     [NXApp getScreenSize:&nxsScreen];
  77.     /* find the lower-left coord */
  78.     nxrResult.origin.x = nxpTopLeft.x;
  79.     nxrResult.origin.y = nxsScreen.height - nxrWinHeight.size.height - nxpTopLeft.y;
  80.     nxrResult.size.width = width;
  81.     nxrResult.size.height = height;
  82.     return (&nxrResult);
  83. }
  84.  
  85. @end
  86.  
  87.